﻿<UserControl x:Class="Sautom.Modules.Proposal.Views.CountryEdit"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:l="clr-namespace:Sautom.ClientComunication.Converters;assembly=Sautom.ClientComunication" mc:Ignorable="d" 
             xmlns:res="clr-namespace:Sautom.I18N;assembly=Sautom.I18N"
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <l:GuidToVisibilityConverter x:Key="GuidToVisibilityConverter" />
        <l:InverseBooleanConverter x:Key="InverseBooleanConverter" />
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="150*" />
            <ColumnDefinition Width="150*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="30" />
            <RowDefinition Height="250*" />
        </Grid.RowDefinitions>
        <Menu Grid.ColumnSpan="2">
            <MenuItem Header="{Binding Source={x:Static res:ProposalResources.SaveBtn}}" Command="{Binding SaveCountryCommand}" CommandParameter="true" />
            <MenuItem Header="{Binding Source={x:Static res:ProposalResources.CancelBtn}}" Command="{Binding SaveCountryCommand}" CommandParameter="false"/>
        </Menu>
        <StackPanel Grid.Row="1">
            <Label Content="{Binding Source={x:Static res:ProposalResources.CountryLabel}}" />
            <TextBox Text="{Binding CountryName}" />

            <Border BorderThickness="2">
                <StackPanel>
                    <Label Content="{Binding Source={x:Static res:ProposalResources.CitiesLabel}}" />
                    <DockPanel>
                        <TextBox MinWidth="150" Name="cityTextbox" DockPanel.Dock="Left" HorizontalAlignment="Left" />
                        <Button Content="{Binding Source={x:Static res:ProposalResources.AddCityBtn}}" Command="{Binding AddCityCommand}" CommandParameter="{Binding ElementName=cityTextbox, Path=Text}"  DockPanel.Dock="Right" HorizontalAlignment="Right" Click="AddCityButtonClear_Click" />
                    </DockPanel>                                        
                    <ListBox ItemsSource="{Binding Cities}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <DockPanel>
                                    <TextBox BorderThickness="0" Text="{Binding CityName, UpdateSourceTrigger=PropertyChanged}" DockPanel.Dock="Left" HorizontalAlignment="Left" />
                                    <Button Width="26" Height="26" Content="X" DockPanel.Dock="Right" HorizontalAlignment="Right" Visibility="{Binding Id, Converter={StaticResource GuidToVisibilityConverter}}"
                                            Command="{Binding Path=DataContext.RemoveCityFromList, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}" CommandParameter="{Binding CityName}"/>
                                </DockPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </StackPanel>
            </Border>
            
            <Border BorderThickness="2">
                <StackPanel>
                    <Label Content="{Binding Source={x:Static res:ProposalResources.DocumentsLabel}}" />
                    <DockPanel>
                        <TextBox MinWidth="150" Name="documentTextbox" DockPanel.Dock="Left" HorizontalAlignment="Left" />
                        <Button Content="{Binding Source={x:Static res:ProposalResources.AddDocumentBtn}}" DockPanel.Dock="Right" HorizontalAlignment="Right"
                                Command="{Binding AddDocumentCommand}" CommandParameter="{Binding ElementName=documentTextbox, Path=Text}" Click="AddDocumentButtonClear_Click" />
                    </DockPanel>
                    <ListBox ItemsSource="{Binding EmbassyDocuments}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <DockPanel>
                                    <TextBox BorderThickness="0" Text="{Binding DocumentName, UpdateSourceTrigger=PropertyChanged}" DockPanel.Dock="Left" HorizontalAlignment="Left" />
                                    <CheckBox IsChecked="{Binding IsArchival, Converter={StaticResource InverseBooleanConverter}}" DockPanel.Dock="Right" HorizontalAlignment="Right" />
                                </DockPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </StackPanel>
            </Border>
        </StackPanel>
    </Grid>
</UserControl>
